package com.webdev.newtech.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.webdev.newtech.domain.TlNotice;
import com.webdev.newtech.mapper.ITlNoticeMapper;
import com.webdev.newtech.service.ITlNoticeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ITlNoticeServiceImpl implements ITlNoticeService {
    @Resource
    ITlNoticeMapper noticeMapper;


    @Override
    public int add(TlNotice notice) {
        return noticeMapper.insert(notice);
    }

    @Override
    public int remove(Integer id) {
        return noticeMapper.deleteById(id);
    }

    @Override
    public int update(TlNotice notice) {
        return noticeMapper.updateById(notice);
    }

    @Override
    public List<TlNotice> getList(TlNotice notice) {
        QueryWrapper<TlNotice>wrapper=new QueryWrapper<>();
        wrapper.eq(notice.getStatus()!=null,"status",notice.getStatus() );
        wrapper.orderByAsc("order_num");
        return noticeMapper.selectList(wrapper);
    }

    @Override
    public TlNotice getById(Integer id) {
        return noticeMapper.selectById(id);
    }
}
